#pragma once


#ifndef __CANVAS_COLLECTION_INTERFACE_H
#define __CANVAS_COLLECTION_INTERFACE_H

#include "..\Objects.h"

namespace Canvas
{
	namespace Collection
	{
		template<class T>
		class IEnumerator abstract : public Interface
		{
		public:
			typedef T ElementType;
			virtual IEnumerator<T>* Clone() const = 0;
			virtual const T& Current() const = 0;
			virtual int Index() const = 0;
			virtual bool Next() = 0;
			virtual void Reset() = 0;
			virtual bool Evaluated() const { return false; }
		};

		template<class T>
		class IEnumerable abstract : public Interface
		{
		public:
			typedef T ElementType;
			virtual IEnumerator<T>* CreateEnumerator() const = 0;
		};

		namespace RandomAccessInternal
		{
			template<class T>
			struct RandomAccessable
			{
				static const bool CanRead = false;
				static const bool CanResize = false;
			};

			template<class T>
			struct RandomAccess
			{
				static size_t GetCount(const T& t)
				{
					return t.Count();
				}

				static const typename T::ElementType& GetValue(const T& t, size_t index)
				{
					return t.Get(index);
				}

				static void SetCount(const T& t, size_t count)
				{
					t.ReSize(count)
				}

				static void SetValue(const T& t, size_t index, const typename T::ElementType& value)
				{
					t.Set(index, value);
				}

				static void AppendValue(const T& t, const typename T::ElementType& value)
				{
					t.Add(value);
				}
			};
		}
	}
}

#endif // __CANVAS_COLLECTION_INTERFACE_H